package com.bw.service.impl;

import com.bw.domain.SysUser;
import com.bw.mapper.SysUserMapper;
import com.bw.mapper.SysUserPostMapper;
import com.bw.mapper.SysUserRoleMapper;
import com.bw.service.SysUserPostService;
import com.bw.service.SysUserRoleService;
import com.bw.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper mapper;
    @Autowired
    private SysUserRoleService  sysUserRoleService;
    @Autowired
    private SysUserPostService  sysUserPostService;
    @Override
    public List<SysUser> lists(SysUser user) {
        return mapper.lists(user);
    }

    @Override
    public boolean save(SysUser user) {
        int save = mapper.save(user);
            if(save>0){
                sysUserRoleService.add(user.getUserId(),user.getRoleId());
                sysUserPostService.add(user.getUserId(),user.getPostId());
            }
        return save>0;
    }

    @Override
    public boolean delete(Integer id) {
        return mapper.delete(id);
    }

    @Override
    public boolean update(SysUser user) {
        return mapper.update(user);
    }

    @Override
    public List<SysUser> list() {
        return mapper.list();
    }

    @Override
    public List<Map<String, Object>> zList() {
        return mapper.zList();
    }

    @Override
    public void insertUser(SysUser user) {
        mapper.insertUser(user);
    }




}
